﻿--[[
   @brief    game manager view
   @author   hqzheng
   @version  1.0
   @date     2015-06-20
--]]

game_mgr_view = {
  
    game_mgr_btn_id = 0;
    MOUDLE_STATE = {
        NORMAL = 0,
        SELECTED = 1,
    };

    btn_background = {};
    is_first_init = true;

    init = function()
        base_utility.log("[game_mgr_view] init success");
        game_mgr_view.game_mgr_btn_id = ui_utility.get_ctrl_id_by_cid(
            CID_MAINFRAME_GAMES_MGR_BTN);
        if true == game_mgr_view.is_first_init then
            game_mgr_view.init_btn_background();
            game_mgr_view.is_first_init = false;
        end
    end;

    inner_log = function (msg, core_msg)
        base_utility.log(string.format("[game_mgr_view] %s", msg), core_msg);
    end;

    init_btn_background = function ()

        game_mgr_view.btn_background[game_mgr_view.MOUDLE_STATE.NORMAL] = {
                background = "ONEIMAGE:client_mainframe\\mainframe_icon.png?150,100,162,112;Center;null;",
                background_hover = "ONEIMAGE:client_mainframe\\mainframe_icon.png?170,100,182,112;Center;null;",
                background_press = "ONEIMAGE:client_mainframe\\mainframe_icon.png?150,100,162,112;Center;null;",
        };

        game_mgr_view.btn_background[game_mgr_view.MOUDLE_STATE.SELECTED] = {
                background = "ONEIMAGE:client_mainframe\\mainframe_icon.png?170,100,182,112;Center;null;",
                background_hover = "ONEIMAGE:client_mainframe\\mainframe_icon.png?170,100,182,112;Center;null;",
                background_press = "ONEIMAGE:client_mainframe\\mainframe_icon.png?170,100,182,112;Center;null;",
        };
    end;

    on_game_mgr_btn_click = function (uilib, control_id, x, y)
        game_mgr_view.inner_log("[on_game_mgr_btn_click]");
        local param = {};
        param.module_id = GAME_ID.GAEM_ID_HOME_PAGE;
        param.module_url = banner_model.get_sub_url_by_game_id(GAME_ID.GAEM_ID_HOME_PAGE, "game_type");
        event_center.send_event(banner_event.JUMP_MODULE_WEB, base_utility.table_to_json(param));
        tqos_mgr.remember_btn_clicked("MAINWINDOW_GAME_MGR_BTN");
    end;

    -- 选中游戏管家模块
    select_game_mgr_module = function (is_select)
        if true == is_select then
            ui_utility.setproperty_by_id(
                game_mgr_view.game_mgr_btn_id,
                "Background",
                game_mgr_view.btn_background[game_mgr_view.MOUDLE_STATE.SELECTED].background);
            ui_utility.setproperty_by_id(
                game_mgr_view.game_mgr_btn_id,
                "BackgroundHover",
                game_mgr_view.btn_background[game_mgr_view.MOUDLE_STATE.SELECTED].background_hover);
            ui_utility.setproperty_by_id(
                game_mgr_view.game_mgr_btn_id,
                "BackgroundPressed",
                game_mgr_view.btn_background[game_mgr_view.MOUDLE_STATE.SELECTED].background_press);
        else
            ui_utility.setproperty_by_id(
                game_mgr_view.game_mgr_btn_id,
                "Background",
                game_mgr_view.btn_background[game_mgr_view.MOUDLE_STATE.NORMAL].background);
            ui_utility.setproperty_by_id(
                game_mgr_view.game_mgr_btn_id,
                "BackgroundHover",
                game_mgr_view.btn_background[game_mgr_view.MOUDLE_STATE.NORMAL].background_hover);
            ui_utility.setproperty_by_id(
                game_mgr_view.game_mgr_btn_id,
                "BackgroundPressed",
                game_mgr_view.btn_background[game_mgr_view.MOUDLE_STATE.NORMAL].background_press);
        end
    end;
}
